package com.fu.entry;

import com.fu.domain.Student;
import com.fu.exception.AgeOutOfBoundException;

import java.util.ArrayList;
import java.util.Scanner;

/**
 * @author 付大大
 * @create 2021-01-09 14:15
 */
public class Test {
    public static void main(String[] args) {
        Student student = new Student();

        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入姓名");
        String name = scanner.nextLine();
        student.setName(name);

        while (true) {
            System.out.println("请输入年龄");
            String string = scanner.nextLine();

            try {
                int age = Integer.parseInt(string);
                student.setAge(age);
                break;
            } catch (NumberFormatException e) {
                e.printStackTrace();
                continue;
            } catch (AgeOutOfBoundException e) {
                e.printStackTrace();
                continue;
            }

        }
        System.out.println(student);

    }
}
